#Makefile for bridgebuilder
#
#Author R.D.
#
#Here `$<' is the automatic variable that holds the name
#of the prerequisite and `$@' is the automatic variable
#that holds the name of the target
DebugMode = ON
CC = g++
CFLAGS = -Wall
PROG = openbridgebuilder
LIBS = -lglut -lSDL

MAIN = main.cpp

ifeq ($(DebugMode),OFF)
	CFLAGS = -Wall
	OutDir = ./bin/Release/
else
	CFLAGS = -g -Wall -pedantic
	OutDir = ./bin/Debug/
endif

MY_FLOAT = ./src/utils/MyFloat
MY_FLOAT_TEST = ./test_src/MyFloatTest
GraphDir = ./src/graphics/
UtilsDir = ./src/utils/
TestDir = ./test_src/


all: $(PROG)
Debug:Test
Release:$(PROG)

cleanDebug:clean
cleanRelease:clean
cleanTest:clean

$(PROG): $(MAIN) $(MY_FLOAT)
#move all object files from obj folder to local folder for compilation
#	@mv ./obj/*o ./
	$(CC) $(CFLAGS) $(MAIN) $(MY_FLOAT).cpp $(LIBS) -o $(OutDir)$@


Test: GUI.o MyFloat.o GUITest.o Camera.o CameraTest.o
	$(CC) $(CFLAGS) test.cpp Camera.o CameraTest.o GUI.o GUITest.o MyFloat.o $(LIBS) -o $(OutDir)$@

TestFloat: MyFloatTest.o
	$(CC) $(CFLAGS) test.cpp MyFloatTest.o MyFloat.o $(LIBS) -o $(OutDir)$@

MyFloat.o: $(MY_FLOAT).cpp $(MY_FLOAT).h
	$(CC) $(CFLAGS) $(MY_FLOAT).cpp -c

MyFloatTest.o: MyFloat.o $(MY_FLOAT_TEST).h $(MY_FLOAT_TEST).cpp
	$(CC) $(CFLAGS) $(MY_FLOAT_TEST).cpp $(MY_FLOAT).cpp -c

GUI.o: MyFloat.o $(GraphDir)GUI.h $(GraphDir)GUI.cpp
	$(CC) $(CFLAGS) $(GraphDir)GUI.h $(GraphDir)GUI.cpp -c

Camera.o: MyFloat.o $(GraphDir)Camera.h $(GraphDir)Camera.cpp
	$(CC) $(CFLAGS) $(GraphDir)Camera.h $(GraphDir)Camera.cpp -c

GUITest.o: MyFloat.o $(TestDir)GUITest.h $(TestDir)GUITest.cpp
	$(CC) $(CFLAGS) $(TestDir)GUITest.h $(TestDir)GUITest.cpp -c

CameraTest.o: MyFloat.o Camera.o $(TestDir)CameraTest.h $(TestDir)CameraTest.cpp
	$(CC) $(CFLAGS) $(TestDir)CameraTest.h $(TestDir)CameraTest.cpp -c

clean:
	rm -f $(PROG)
